package com.activiti.common;

import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import java.io.Serializable;

/**
 * Created  on 2019/4/23.
 *
 * @author beike
 * restful的基本规范
 */
public interface RestServiceController<T, ID extends Serializable> {

    @ApiOperation("id查询")
    @GetMapping("{id}")
    Object getOne(@PathVariable("id") ID id);

    @ApiOperation("分页查询")
    @GetMapping
    Object getList(@RequestParam(value = "rowSize", defaultValue = "1000", required = false) Integer rowSize
            , @RequestParam(value = "page", defaultValue = "1", required = false) Integer page);

    @ApiOperation("新增")
    @PostMapping
    Object postOne(@RequestBody T entity);

    @ApiOperation("id更新")
    @PutMapping("{id}")
    Object putOne(@PathVariable("id") ID id, @RequestBody T entity);


    @ApiOperation("id部分更新")
    @PatchMapping("{id}")
    Object patchOne(@PathVariable("id") ID id, @RequestBody T entity);

    @ApiOperation("id删除")
    @DeleteMapping("{id}")
    Object deleteOne(@PathVariable("id") ID id);
}
